package server

import "time"

type ServerReadIdleTimeout struct {
	session *Session
}

func (x *ServerReadIdleTimeout) OnTimeout() {
	x.session.sessionHandle.OnReadIdleTimeout(x.session)
}

func (x *ServerReadIdleTimeout) IsTimeout() bool {
	return x.session.lastReadAt.Add(x.session.readIdleTimeout).Before(time.Now())
}

func NewServerReadIdleTimeout(session *Session) *ServerReadIdleTimeout {
	return &ServerReadIdleTimeout{
		session: session,
	}
}
